package com.jklan.zhiqibackend.utils;

import com.jklan.zhiqibackend.common.ErrorCode;
import com.jklan.zhiqibackend.exception.BusinessException;

public class ExceptionUtil {
    // 断言条件为真，否则抛出异常
    public static void assertTrue(boolean condition, ErrorCode errorCode) {
        if (!condition) {
            throw new BusinessException(errorCode);
        }
    }
    
    // 断言对象不为null
    public static void assertNotNull(Object obj, ErrorCode errorCode) {
        assertTrue(obj != null, errorCode);
    }
    
    // 抛出业务异常
    public static void throwBusinessException(ErrorCode errorCode) {
        throw new BusinessException(errorCode);
    }
}
